package cn.study.controller;


import cn.study.entity.StudyCourse;
import cn.study.entity.StudyIntegral;
import cn.study.entity.StudyVideo;
import cn.study.service.StudyCommodityService;
import cn.study.service.StudyCourseService;
import cn.study.service.StudyVideoService;
import cn.study.service.impl.StudyVideoServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 课程表 前端控制器
 * </p>
 *
 * @author qiao
 * @since 2020-06-22
 */
@Controller
@RequestMapping("/study-course")
public class StudyCourseController {
    @Resource
    StudyCourseService studyCourseService;
    @Resource
    StudyVideoService studyVideoService;

    @GetMapping("/list")
    public List<StudyCourse> list(Model model, @RequestParam(value = "id", required = false) Integer id) {
        List<StudyCourse> list = studyCourseService.getByDepByRoleList(id);
        return list;
    }

    @GetMapping("/details/{id}")
    public String details(Model model, @PathVariable("id") Integer id) {
        StudyCourse studyCourse = studyCourseService.getDetailsList(id);
        QueryWrapper<StudyVideo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("video_course_id", id);
        List<StudyVideo> videoList = studyVideoService.list(queryWrapper);
        model.addAttribute("studyCourse", studyCourse);
        model.addAttribute("videoList", videoList);
        return "details";
    }


}

